home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / jovept2.arc / STAT.C < prev    next >
Text File  |  1985-05-30  |  1KB  |  49 lines

  1. /* stat.c */
  2. /* JOVE/MSDOS. K. Mitchum 1/85 */
  3. /* Ken Mitchum */
  4. /* University of Pittsburgh */
  5. /* Decision Systems Laboratory */
  6.  
  7. /* misc. file functions for ms-dos to simulate stat() call */
  8.  
  9. /* K. Mitchum 1//84 */
  10.  
  11. #include "stat.h"
  12. #define MODE 0
  13. extern unsigned char *filedir();
  14. static unsigned char *filelist;
  15.  
  16.  
  17. struct ff_str { 
  18.   char dummy[21];        /* reserved for dos */ 
  19.   unsigned char attribute;    /* returned attribute */ 
  20.   unsigned time; 
  21.   unsigned date; 
  22.   long size;            /* size of file */ 
  23.   unsigned char fn[13];        /* string containing the filename */ 
  24. }; 
  25.  
  26. stat(filename,stbuf)
  27. unsigned char *filename;
  28. struct stat *stbuf;
  29. {
  30.     unsigned char *p, *q;
  31.     int i = 1;
  32.     p = filename;
  33.     
  34.     for(p = filename;*p; p++)
  35.         if((*p >= 'a') && (*p <= 'z')) *p &= 0x5f;
  36.     q = p = filedir("*.*",MODE);
  37.     while(*p) {
  38.         if(strcmp(p,filename) == 0) {
  39.             stbuf->st_ino = i;
  40.             return(0);
  41.         }
  42.         i++;
  43.         p += strlen(p)+1;
  44.     }
  45.     free(q);
  46.     return(-1);
  47. }
  48. /* end */
  49.